#include <iostream>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
void handle(int sign)
{
    std::cout << "收到了2号信号" << std::endl;
    exit(1);
}
int main()
{
    signal(2, handle);
    while(1)
    {
        std::cout << "aaa" << getpid() << std::endl;
        sleep(1);
    }
    return 0;
}

